//
//  AyReweetStatusView.m
//  xWeibo
//
//  Created by alvis mac on 8/25/15.
//  Copyright (c) 2015 alvis. All rights reserved.
//

#import "AyReweetStatusView.h"
#import "UIImageExtend.h"
#import "AyDefine.h"
#import "AyStatusFrame.h"
#import "UIImageExtend.h"
#import "UIImageView+WebCache.h"
#import "AyStatusTopView.h"
#import "AyReweetStatusView.h"
#import "AyPhoto.h"
#import "AyDefine.h"
#import "AyPhotosView.h"

@interface AyReweetStatusView()

/** 被转发微博作者的昵称 */
@property (nonatomic, weak) UILabel *retweetNameLabel;
/** 被转发微博的正文\内容 */
@property (nonatomic, weak) UILabel *retweetContentLabel;
/** 被转发微博的配图 */
@property (nonatomic, weak) AyPhotosView *retweetPhotoView;

@end


@implementation AyReweetStatusView


- (instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        self.userInteractionEnabled = YES;
        self.image = [UIImage resizedImageWithName:@"timeline_retweet_background" left:0.9 top:0.5];
        
        /** 2.被转发微博作者的昵称 */
        UILabel *retweetNameLabel = [[UILabel alloc] init];
        retweetNameLabel.font = AyRetweetStatusNameFont;
        retweetNameLabel.textColor = AyColor(67, 107, 163);
        retweetNameLabel.backgroundColor = [UIColor clearColor];
        [self addSubview:retweetNameLabel];
        self.retweetNameLabel = retweetNameLabel;
        
        /** 3.被转发微博的正文\内容 */
        UILabel *retweetContentLabel = [[UILabel alloc] init];
        retweetContentLabel.font = AyRetweetStatusContentFont;
        retweetContentLabel.backgroundColor = [UIColor clearColor];
        retweetContentLabel.numberOfLines = 0;
        retweetContentLabel.textColor = AyColor(90, 90, 90);
        [self addSubview:retweetContentLabel];
        self.retweetContentLabel = retweetContentLabel;
        
        /** 4.被转发微博的配图 */
        AyPhotosView *retweetPhotoView = [[AyPhotosView alloc] init];
        [self addSubview:retweetPhotoView];
        self.retweetPhotoView = retweetPhotoView;
        
    }
    return self;
}



-(void)setStatusFrame:(AyStatusFrame *)statusFrame{
    _statusFrame=statusFrame;
    
    AyStatus *retweetStatus = self.statusFrame.status.retweeted_status;
    AyUser *user = retweetStatus.user;
    
    // 1.父控件
    if (retweetStatus) {
        self.hidden = NO;
        self.frame = self.statusFrame.retweetViewF;
        
        // 2.昵称
        self.retweetNameLabel.text = [NSString stringWithFormat:@"@%@", user.name];
        self.retweetNameLabel.frame = self.statusFrame.retweetNameLabelF;
        
        // 3.正文
        self.retweetContentLabel.text = retweetStatus.text;
        self.retweetContentLabel.frame = self.statusFrame.retweetContentLabelF;
        
        // 4.配图
        if (retweetStatus.pic_urls.count) {
            self.retweetPhotoView.hidden = NO;
            self.retweetPhotoView.frame = self.statusFrame.retweetPhotoViewF;
            self.retweetPhotoView.photos = retweetStatus.pic_urls;
        } else {
            self.retweetPhotoView.hidden = YES;
        }
        
    } else {
        self.hidden = YES;
    }

}



@end
